/**
 * Created by Administrator on 2016/4/24.
 */

    var getIp="http://192.168.1.32:3000/";
    //同步数据操作
    $("#synbutton").on("click",function(){
        var params=getSynData();
        var sel= $.Params.create();
        sel.addParams("params",params);
        sel.ajax("http://test.s4s.com.cn/wx/product.action?addMore",function(data){
            if(data.success){
                alert("同步成功");
            }
        })

        //$.ajax({
        //    url:"http://192.168.1.69:8080/wx/product.action?addMore&params="+params,
        //    async:false,
        //    success:function(data){
        //        if(data.success){
        //            alert("同步成功");
        //        }
        //    }
        //})

    })
    function getSynData(){
        var params=[];
        $.ajax({
            url:getIp+"product/list",
            async:false,
            success:function(data){
                if(data.success){
                    var d=new Date();
                    var createTime=d.format('yyyy-MM-dd hh:mm:ss');
                    $.each(data.rows,function(i,val){
                        var paramT="{\"id\":\""+val._id+"\",\"stageId\":\""+val.stageId+"\",\"progressId\":\""+val.progressId+"\",\"progressName\":\""+val.progressName+"\",\"productName\":\""+val.productName+"\",\"remark\":\""+val.remark+"\",\"createTime\":\""+createTime+"\"}";
                        params.push(paramT);
                    })
                    params="["+params+"]";

                    }

                }

        })
        return params;

    }

